/**
 * Copyright 2010 Adam Ruggles.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package saig.engine.enums;

/**
 * GameStatus Enum, defines the status the game is in.
 * @author Adam
 * @version $Id$
 * 
 * Created on Aug 8, 2010 at 8:58:42 AM 
 */
public enum GameStatus {
	LOSS(0), RUNNING(1), WON(2);
	/**
	 * Returns a GameStatus from it's integer value.
	 * @param value The value of the game status.
	 * @return A GameStatus from it's integer value.
	 */
	public static GameStatus fromInt(final int value) {    
		switch(value) {
            case 1:
            	return RUNNING;
            case 2:
            	return WON;
            default:
            	return LOSS;
        }
	}
	/**
	 * The value of the game status.
	 */
	private final int value;
	/**
	 * Private GameStatus constructor.
	 * @param value The value associated with the game status.
	 */
	private GameStatus(final int value) {
		this.value = value;
	}
	/**
	 * Returns the integer value of the game status.
	 * @return The integer value of the game status.
	 */
	public int toInt() {
		return value;
	}
	/**
	 * Returns a string representation of the game status.
	 * {@inheritDoc}
	 * @see java.lang.Enum#toString()
	 */
	public String toString() {
		switch(this) {
		case RUNNING:
			return "Running";
		case WON:
			return "Won";
		case LOSS:
			return "Loss";
		default:
			return "UNKNOWN";
		}
	}
}
